﻿Imports extremo
Public Class UsuariosForm

    Private Sub btnNuevo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNuevo.Click

        Dim form As New UsuarioNuevoForm
        form.MdiParent = Me.MdiParent
        form.usuariosForm = Me
        form.Show()
    End Sub

    Private Sub UsuariosForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        With Me.dgvUsuarios.ColumnHeadersDefaultCellStyle
            .BackColor = Color.Red
            .ForeColor = Color.White
        End With

    End Sub

    Private Sub btnBuscar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBuscar.Click
        Dim criterio As String = Me.txtBuscar.Text
        'MsgBox(criterio)

        Dim negocio As New UsuarioNegocio
        Dim usuarios As Collection = negocio.buscarPorNombre(criterio)
        Me.dgvUsuarios.DataSource = usuarios
        Me.dgvUsuarios.EditMode = False

        Me.dgvUsuarios.Columns(0).HeaderText = "Id"
        Me.dgvUsuarios.Columns(1).HeaderText = "Nombre"
        Me.dgvUsuarios.Columns(2).HeaderText = "ap_paterno"
        Me.dgvUsuarios.Columns(3).HeaderText = "ap_materno"
        Me.dgvUsuarios.Columns(4).HeaderText = "Edad"
        Me.dgvUsuarios.Columns(5).HeaderText = "Usuario"
        Me.dgvUsuarios.Columns(6).HeaderText = "Contraseña"
        Me.dgvUsuarios.Columns(7).HeaderText = "Direccion"
        Me.dgvUsuarios.Columns(8).HeaderText = "Distrito"
        Me.dgvUsuarios.Columns(9).HeaderText = "Telefono"
        Me.dgvUsuarios.Columns(10).HeaderText = "Email"
        Me.dgvUsuarios.Columns(11).HeaderText = "Sexo"
    End Sub

    Private Sub txtBuscar_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtBuscar.TextChanged

    End Sub

    Private Sub btnEliminar_Click(sender As System.Object, e As System.EventArgs) Handles btnEliminar.Click
        Dim seleccionado = Me.dgvUsuarios.CurrentRow.Cells(0).Value.ToString
        Dim negocio As New UsuarioNegocio
        negocio.eliminar(seleccionado)
        dgvUsuarios.DataSource = ""
        MsgBox("Usuario eliminado!!!!")
    End Sub

    Private Sub btnSalir_Click(sender As System.Object, e As System.EventArgs) Handles btnSalir.Click
        Me.Close()
    End Sub
End Class
